package com.cskaoyan.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

/**
 * @author stone
 * @date 2021/11/19 15:03
 */
//类似于InvocationHandler
@Component
public class CustomAdvice implements MethodInterceptor {

    //代理对象执行MethodInterceptor的invoke方法 👉 类似于InvocationHandler
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("正道的光2.0");
        //委托类方法的执行 👉 类似于动态代理阶段的method.invoke
        Object proceed = methodInvocation.proceed();
        System.out.println("照在大地上2.0");
        return proceed;
    }
}
